import { http } from '@/utils/http'

// 新增
export const appAdd = (data?: object) => {
  return http.request('post', '/app/app', { data })
}
// 编辑
export const costMgtUpdate = (data?: object) => {
  return http.request('post', '/app/update', { data })
}

// 列表
export const getList = (params?: object) => {
  return http.get<{}, HttpPaginationResponse>('/manage/myApplyInfo/use', { params })
}

// 列表
export const getMyApiList = (params?: object) => {
  return http.get<{}, HttpPaginationResponse<Array<MyApiListItem>>>('/manage/myApplyInfo/myApis', {
    params,
  })
}

// 详情信息
export const getDetail = (params?: number) => {
  return http.request('get', '/manage/approve/apiApplyInfo', {
    params: { applyId: params },
  })
}
// 删除
export const deleteApplication = (ids: string) => {
  return http.request('delete', `/manage/myApplyInfo/use/${ids}`)
}

/**
 * 接口申用申请撤回
 * @param id
 * @returns
 */
export const revokeApply = (id: string) => {
  return http.request('put', '/manage/myApplyInfo/use/revoke', {
    params: { applyId: id },
  })
}

export type MyApiListItem = {
  id: string
  apiName: string
  createBy: string
  createTime: string
  checkStatus: string
  checkBy?: any
  checkTime?: any
  updateTime: string
  requestPath: string
  apiType: string
  applyStatus: string
  enabledStatus: string
}
